import { resolve } from 'path'
import { defineConfig, externalizeDepsPlugin } from 'electron-vite'
import vue from '@vitejs/plugin-vue'

export default defineConfig({
  main: {
    plugins: [externalizeDepsPlugin()],
    build: {
      lib: {
        entry: {
          main: resolve('src/main/main.js'),
          'config-manager': resolve('src/shared/config-manager.js'),
          'plugins/core/manager': resolve('src/plugins/core/manager.js'),
          'plugins/loader': resolve('src/plugins/loader/index.js'),
          'preload': resolve('src/main/preload.js')
        }
      },
      rollupOptions: {
        output: {
          format: 'cjs'
        }
      }
    }
  },
  preload: {
    plugins: [externalizeDepsPlugin()],
    build: {
      lib: {
        entry: resolve('src/main/preload.js')
      }
    }
  },
  renderer: {
    root: resolve('src/renderer'),
    build: {
      rollupOptions: {
        input: resolve('src/renderer/index.html')
      }
    },
    resolve: {
      alias: {
        '@': resolve('src/renderer'),
        'vue': 'vue/dist/vue.esm-bundler.js'
      }
    },
    plugins: [vue()]
  }
})